/*
 * 
 * LegendShop 多用户商城系统
 * 
 *  版权所有,并保留所有权利。
 * 
 */
package com.legendshop.oa.dao.impl;

import com.legendshop.dao.impl.GenericDaoImpl;
import com.legendshop.dao.support.CriteriaQuery;
import com.legendshop.dao.support.EntityCriterion;
import com.legendshop.dao.support.PageSupport;
import com.legendshop.oa.dao.DepartmentDao;
import com.legendshop.oa.model.Department;

import java.util.List;

/**
 * The Class DepartmentDaoImpl.
 */

public class DepartmentDaoImpl extends GenericDaoImpl<Department, Long> implements DepartmentDao  {
     
    public List<Department> getDepartment(String userName){
   		return this.queryByProperties(new EntityCriterion().eq("userName", userName));
    }

	public Department getDepartment(Long id){
		return getById(id);
	}
	
    public int deleteDepartment(Department department){
    	return delete(department);
    }
	
	public Long saveDepartment(Department department){
		return save(department);
	}
	
	public int updateDepartment(Department department){
		return update(department);
	}
	
	public PageSupport getDepartment(CriteriaQuery cq){
		return queryPage(cq);
	}

	/**
	 * 获取所有的部门
	 */
	@Override
	public List<Department> getAllDepartment() {
		return queryAll();
	}

	/**
	 * 根据ID来查找名字
	 */
	@Override
	public String getDepartmentName(Long deptId) {
		return get("select name from ls_department where id = ?", String.class, deptId);
	}
	
 }
